from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        groups = {}
        for str in strs:
            a = self.decode(str)
            if a not in groups:
                groups[a] = []
            groups[a].append(str)
        return list(groups.values())
    def decode(self,s):
        code = [0] * 26
        for c in s:
            d = ord(c)-ord('a')
            code[d] += 1
        return ''.join(map(chr, code))
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    solution.groupAnagrams(["eat","tea","tan","ate","nat","bat"])
    # your test code here